#include "main_interface.h"
#include "ui_main_interface.h"
#include "dashboard_widget3.h"

MainInterface::MainInterface(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainInterface)
{
    ui->setupUi(this);

    //发动机转速表
    DashBoardWidget3 *dashBoardWidget5 = new DashBoardWidget3(this);
    dashBoardWidget5->setScaleMajor(6);//6个大区间
    dashBoardWidget5->setScaleMinor(5);//每个区间5个小格
    dashBoardWidget5->setUnit("");
    dashBoardWidget5->setText("RPMx100");
    dashBoardWidget5->setmax(30);
    dashBoardWidget5->setUnitDrawInterval(1);//每隔一个大区间画一个刻度线描述值
    dashBoardWidget5->setGeometry(20, 20, 300, 300);

    connect(this, &MainInterface::sendEngineSpeed,
            dashBoardWidget5, &DashBoardWidget3::valueChanged);

    ui->horizontalSlider->setRange(0, 30);
    connect(ui->horizontalSlider, &QSlider::valueChanged,
            this, [&](double value){
        emit sendEngineSpeed(value);
    });

}

MainInterface::~MainInterface()
{
    delete ui;
}
